package com.zhiwei.codesecurity.common.webservice.checkmarx.wsdk.client;

import com.zhiwei.codesecurity.common.webservice.checkmarx.portal.v7.*;
import com.zhiwei.codesecurity.common.webservice.checkmarx.wsdk.args.ZipArgs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ZipPortalClient extends PortalClient<ZipArgs> {
    private final static Logger logger = LoggerFactory.getLogger(ZipPortalClient.class);

    public ZipPortalClient(ZipArgs zipArgs) {
        super(zipArgs);
    }

    /**
     * Create SourceCodeSettings; 配置源码获取相关属性
     * @return
     */
    public SourceCodeSettings createSourceCodeSettings() {
        logger.info(">>>>>>>>开始设置本地上传扫描代码配置");
        LocalCodeContainer container = new LocalCodeContainer();
        container.setFileName(this.args.getZipName());
        container.setZippedFile(this.args.getZipBytes());
        logger.info(">>>>>>>LocalCodeContainer设置完成|container:{}", container);

        SourceCodeSettings codeSettings = new SourceCodeSettings();
        codeSettings.setSourceOrigin(SourceLocationType.LOCAL);
        codeSettings.setPackagedCode(container);
        logger.info(">>>>>>>SourceCodeSettings设置完成|codeSettings:{}", container);
        return codeSettings;
    }

    public static void main( String[] args ) {
        ZipArgs zipArgs = new ZipArgs();
        zipArgs.setSdkUrl("http://61.147.125.143:1088/cxwebinterface/portal/cxwebservice.asmx?wsdl");
        zipArgs.setSdkUsr("admin");
        zipArgs.setSdkPwd("Admin@2018");

        ZipPortalClient portalClient = new ZipPortalClient(zipArgs);
        int queueCount = ZipPortalClient.getQueueCount(portalClient);
        System.out.println("QueueCount: " + queueCount);
        portalClient.logout();
    }
}
